//
//  CPBaseNavController.swift
//  ComponentUI
//
//  Created by wrs on 2018/7/18.
//  Copyright © 2018年 wrs. All rights reserved.
//

import UIKit

open class CPBaseNavController: UINavigationController, UIGestureRecognizerDelegate {
    deinit {
#if DEBUG
        print("[Line \(#line)] ----------\(NSStringFromClass(self.classForCoder))  deinit---------")
#endif
    }
    
   open override func viewDidLoad() {
        super.viewDidLoad()
        self.interactivePopGestureRecognizer?.delegate = self
    }

   open override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    open override var shouldAutorotate: Bool {
        get {
            var flag: Bool = super.shouldAutorotate
            if let topVC = self.topViewController {
                flag = topVC.shouldAutorotate
            }
            return flag
        }
    }
    // MARK: - UIGestureRecognizerDelegate
    open func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        if self.viewControllers.count == 1 {
            return false
        } else {
            return true
        }
    }

}
